package com.moss.cloud.common.file.factory;

import com.moss.cloud.common.file.constant.StorageTypeEnum;
import com.moss.cloud.common.file.operation.FileStorageOperation;
import com.moss.cloud.common.file.realize.GoFastDfsStorage;
import com.moss.cloud.common.file.realize.MinioStorage;
import com.moss.cloud.common.file.realize.TencentStorage;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * 存储工厂
 *
 * @author 瑾年
 * @date 2023年4月19日
 */
public class FileStorageFactory {
    static Map<String, FileStorageOperation> operationMap = new HashMap<>();

    static {
        operationMap.put(StorageTypeEnum.TENCENT_CLOUD.code(), new TencentStorage());
        operationMap.put(StorageTypeEnum.MIN_IO.code(), new MinioStorage());
        operationMap.put(StorageTypeEnum.GO_FASTDFS.code(), new GoFastDfsStorage());
    }

    public static Optional<FileStorageOperation> storageType(String type) {
        return Optional.ofNullable(operationMap.get(type));
    }
}
